package com.mcxx.modules.miniSalvation.family.service.read;

import com.mcxx.modules.base.utils.QueryParamUtil;
import com.mcxx.modules.miniSalvation.family.dto.OrganizationDTO;
import com.mcxx.modules.miniSalvation.family.entity.OrganizationEntity;
import com.mcxx.modules.miniSalvation.family.dao.read.OrganizationReadDao;
import com.mcxx.modules.miniSalvation.family.param.OrganizationParam;
import com.mcxx.util.DateUtil;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.service.BaseService;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("organizationReadService")
@TaTransactional(readOnly = true)
public class OrganizationReadService extends BaseService {

    @Autowired
    private OrganizationReadDao organizationReadDao;


    public List<OrganizationEntity> listAll() {
    	return organizationReadDao.listAll();
    }



    public OrganizationEntity getById(String id) {
    	return organizationReadDao.getById(id);
    }


    public Page queryOrganizationList(OrganizationParam param, PageParam pageParam, UserAccountVo userAccount){
        QueryParamUtil.setBaseParamValue(param,userAccount);
        param.setSendMonth(DateUtil.getMonthString());
        organizationReadDao.beginPager(pageParam);
        List<OrganizationDTO> list = organizationReadDao.queryOrganizationList(param);
        return organizationReadDao.endPager(list);
    }


    public int checkName(String name){return organizationReadDao.checkName(name);}



    public List<OrganizationEntity> getOldAgeHomesByAreaCode(String areaCode){

        return  organizationReadDao.getOldAgeHomesByAreaCode(areaCode);
    }

    public List<OrganizationEntity> queryOrgByIds(String[] ids){
        return organizationReadDao.queryOrgByIds(ids);
    }


    public List<OrganizationDTO> exportOrganizationList(OrganizationParam param){return organizationReadDao.queryOrganizationList(param);};
}
